$(document).ready(function(){
	doDetail($("#staffId").val());
});
var orgTypeSet = {
		"F":"主岗",
		"T":"兼职",
		"J":"借调"
};
//展示人员信息
function doDetail(staffId){
	$.post(prc + '/sysStaffController/searchStaffMapById.action?temp='+(new Date().getTime()),{'id':staffId},function(data){
		var sysStaff = data.staffInfo;
		for(var col in sysStaff){
			if(col == 'sex'){
				$("#sexInfoObj").html(sysStaff[col]==='M'?'男':'女');
			}else if(col == 'staffStatus'){
				$("#staffStatusInfoObj").html(sysStaff[col]==='1'?'有效':'无效');
			}/*else if(col == 'hireDate'){
				$("#hireDateInfoObj").html(getSmpFormatDateByLong(sysStaff[col],false));
			}*/else{
				$('#'+col+'InfoObj').html(sysStaff[col]);
			}
		}
		if(sysStaff.staffKind == '1'){
			$(".photo").show();
	    	$("#polciePhoto").attr("src",prc+"/staffForPolice/getPhoto?staffId="+sysStaff.staffId+"&t="+(new Date().getTime()));
		}
		var staffOrgs = data.staffOrgs;
		$("#staffOrgInfos").empty();
		for(var i in staffOrgs){
			$("#staffOrgInfos").append("<div class=\"form-group col-sm-12\">");
			$("#staffOrgInfos").append("<div class=\"input-group\" style=\"width:48%;margin-right:5px;float:left;\">\
					<label class=\"input-group-addon\">组织名称</label>\
					<span class=\"form-control\">"+staffOrgs[i].orgName+"</span></div>");
			/*$("#staffOrgInfos").append("<div class=\"input-group\" style=\"width:48%;margin-right:5px;float:left;\">\
					<label class=\"input-group-addon\">岗位类型</label>\
					<span class=\"form-control\">"+orgTypeSet[staffOrgs[i].staffOrgType]+"</span></div>");
			$("#staffOrgInfos").append("<div class=\"input-group\" style=\"width:48%;margin-right:5px;float:left;\">\
					<label class=\"input-group-addon\">入职日期</label>\
					<span class=\"form-control\">"+(staffOrgs[i].hireDate?staffOrgs[i].hireDate:"")+"</span></div>");
			$("#staffOrgInfos").append("<div class=\"input-group\" style=\"width:48%;margin-right:5px;float:left;\">\
					<label class=\"input-group-addon\">生效日期</label>\
					<span class=\"form-control\">"+(staffOrgs[i].effectStartDate?staffOrgs[i].effectStartDate:"")+"</span></div>");
			$("#staffOrgInfos").append("<div class=\"input-group\" style=\"width:48%;margin-right:5px;float:left;\">\
					<label class=\"input-group-addon\">结束日期</label>\
					<span class=\"form-control\">"+(staffOrgs[i].effectEndDate?staffOrgs[i].effectEndDate:"")+"</span></div>");*/
			$("#staffOrgInfos").append("</div>");
		}
		var roles = data.roles;
		if(roles.length>0){
			$("#roleDiv").empty();
			for(var i in roles){
				$("#roleDiv").append("<div class=\"form-group col-sm-12\">");
				$("#roleDiv").append("<div class=\"input-group\" style=\"width:48%;margin-right:5px;float:left;\">\
						<label class=\"input-group-addon\">角色名称</label>\
						<span class=\"form-control\">"+(roles[i].roleName?roles[i].roleName:"")+"</span></div>");
				$("#roleDiv").append("<div class=\"input-group\" style=\"width:48%;margin-right:5px;float:left;\">\
								<label class=\"input-group-addon\">角色描述</label>\
								<span class=\"form-control\">"+(roles[i].roleDesc?roles[i].roleDesc:"")+"</span></div>");
				$("#roleDiv").append("</div>");
			}
		}else{
			$("#roleDiv").detach();
			$("#role").append("<h5>无角色数据</h5>")
		}
		var permissions = data.permissions;
		if(permissions.length>0){
			$.fn.zTree.destroy("permTree");
			var permTree = $.fn.zTree.init($("#permTree"), {data: {simpleData: {enable: true}}},permissions);
		}else{
			$("#permTree").detach();
			$("#permission").append("<h5>无权限数据</h5>")
		}
		$('#infoModal').modal({'show':true});
		$('#infoTab a:first').tab('show')
	});
}